
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/main.css'/>"/>
    <script type="text/javascript" src="<c:url value='/resource/js/jquery-1.11.1.min.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/resource/js/num-alignment.js'/>"></script>
    <title>注册账号审核</title>
</head>
<body>
<div class="btn_box4">
    <a href="profile/index.html" class=" back">返回</a>
    <a href="profile/logout" class=" logout">注销</a>
</div>
<form action="zhsh/index" id="" method="post">
    <ul class="zczh_sh">
        <li>
            <i>公司名称</i>
            <input class="gsname" type="text" placeholder="请输入公司名称" name="company" id="company" value="${user.company}"/>
        </li>
        <li>
            <i>联系人</i>
            <input class="gsname" type="text" placeholder="请输入联系人" name="realname" id="realname" value="${user.realname}"/>
        </li>

    </ul>
    <div class="btn_box">
        <input type="button" value="查询" class="search_btn all_btn" onclick="submit();"/>
    </div>
</form>
<div class="zczh_ch_tab">
    <table width="100%"  border="0" cellspacing="0" cellpadding="0" class="table">
        <thead class="thead">
        <tr>
            <td width="62%">公司名称</td>
            <td width="20%">联系人</td>
            <td width="18%" class="nobg">操作</td>
        </tr>
        </thead>
        <tbody id="_tbody">
        <%--<tr>
            <td>苏州祥发智能工程有限公司</td>
            <td>王来祥</td>
            <td class="shenbao">
                通过
            </td>
        </tr>--%>
        <c:if test="${!empty pager.list}" >
            <c:forEach items="${pager.list}" var="list" varStatus="status">
                <tr>
                    <td>${list.company}</td>
                    <td>${list.realname}</td>
                    <td class="shenbao" onclick="approval('${list.guid}',this);">
                         通过
                    </td>
                </tr>
            </c:forEach>
        </c:if>
        <c:if test="${empty pager.list}" >
            <tr><td colspan="3">未查出数据</td></tr>
        </c:if>
        </tbody>
    </table>
    <a class="click_more" onclick="queryMore();" id="queryMore">点击查看更多信息...</a>
 </div>
</div>
</body>
<script type="text/javascript">
    var totlePage = "${pager.page}";//总页数
    var pageNum = "${pager.pageNum}";//当前页数
    var total = "${pager.total}";//总数据量
    $(function () {
        hide_queryMore();
    });
    //加载更多
    function queryMore() {
        if (pageNum < totlePage) {
            pageNum++;
        }
        $.ajax({
            url: "zhsh/getMore",
            type: "post",
            async: false,
            dataType: "json",
            data: {
                company: $("#company").val(),
                realname: $("#realname").val(),
                pageNum: pageNum
            },
            success: function (resp) {
                if (resp.succ && resp.data.list.length > 0) {
                    var data = resp.data.list;
                    var html = "";
                    for (var i = 0; i < data.length; i++) {
                        html += "<tr>" +
                                "<td>" + data[i].company + "</td>" +
                                "<td>" + data[i].realname + "</td>" +
                                "<td class=\"shenbao\" onclick=\"approval('"+data[i].guid+"',this);\">通过</td></tr>";
                    }
                    $("#_tbody").append(html);
                    hide_queryMore();//判断是否影藏获取更多按钮
                    /*window.location.href="profile/index";*/
                } else {
                    alert("请求错误");
                    return false;
                }
            }
        });
    }
    //加载更好按钮隐藏
    function hide_queryMore(){
        if(pageNum == totlePage ){
           $("#queryMore").hide();
        }
    }
    function approval(guid,obj){
        if(!confirm("确定要通过此账号吗？")){
            return false;
        }else{
            $.ajax({
                url: "zhsh/approval",
                type: "post",
                async: false,
                dataType: "json",
                data: {
                    guid: guid
                },
                success: function (resp) {
                    if (resp.succ) {
                        alert(resp.msg);
                        $(obj).parent().remove();
                    } else {
                        alert(resp.msg);
                        return false;
                    }
                }
            });
        }
    }
</script>
</html>